﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ContaSuite.Model
{
    class ClientModel
    {
        private db_contasuiteEntities ctx;

        public ClientModel()
        {
            ctx = new db_contasuiteEntities();
        }

        public List<x_client> GetAllClients()
        {
            try
            {
                List<x_client> toReturn;
                var result = ctx.x_client.Select(a => a);
                toReturn = result.ToList();
                return toReturn;
            }
            catch (Exception)
            {
                
                throw;
            }
        }

        public List<x_client> GetClients(string matchString)
        {
            try
            {
                List<x_client> toReturn;
                var result = ctx.x_client
                    .Where(a=>a.client_name.Contains(matchString))
                    .Select(a => a);
                toReturn = result.ToList();
                return toReturn;
            }
            catch (Exception)
            {

                throw;
            }
        }

        
    }
}
